<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>v-bind实例</title>
    <script src="../assets/js/vue.js"></script>
    <style>
        .classA{
            color: red;
        }
        .classB{
            font-size: 150%;
        }
    </style>
</head>
<body>
    <h1>v-bind实例</h1>
    <hr/>
    <div id="app">
        <p><img v-bind:src='imgSrc'/></p>
        <p><a :href="webUrl" target="_blank">百度</a></p>
        <hr/>
        <div :class="className">1.绑定Class</div>
        <div :class="{classA:isOk}">2.绑定Class中的判断</div>
        <div :class="[classA,classB]">3.绑定Class中的数组</div>
        <div :class="isOk?classA:classB">4.绑定Class中的三元运算符</div>
        <hr/>
        <div>
            <input type="checkbox" id="isOk" v-model="isOk"/>
            <label for="isOk">isOk={{isOk }}</label>
        </div>
        <hr/>
        <!--
            :style={color:red,fontSize:fontSize}
            然后要在data中定义red和fontSize,注意这里要使用驼峰法来写fontSize(对应css中的font-size)
        -->
        <div :style="myStyle">5.绑定style</div>
    </div>



    <script>
        var app = new Vue({
            el: '#app',
            data: {
                imgSrc: 'http://7xjyw1.com1.z0.glb.clouddn.com/20170227001137.jpg',
                webUrl: 'https://www.baidu.com',
                className: 'classA',
                isOk: false,
                classA: 'classA',
                classB: 'classB',
                myStyle: {
                    color: 'red',
                    'fontSize': '50px'
                }
            }
        });
    </script>

</body>
</html>